#include "EpilProgramParser.h"
#include "EpilStatementParser.h"
#include "EpilParser.h"


EpilProgramParser::EpilProgramParser( const EpilParser * parser )
: EpilSyntaxParser( parser )
{
}


EpilProgramParser::~EpilProgramParser()
{
}


EpilProgramCode * EpilProgramParser::Parse( const list<EpilToken>::const_iterator & itBegin, list<EpilToken>::const_iterator & itEnd )
{
	EpilProgramCode * program = new EpilProgramCode();

	list<EpilToken>::const_iterator it = itBegin;;
	while( it != itEnd ) 
	{
		EpilStatementParser statementParser( this->GetParser() );
		EpilStatementCode * statement = statementParser.Parse( it, it );
		if( statement )
		{
			program->GetStatements().push_back( statement );
		}
		else
		{
			break;
		}
	}

	return program;
}